package com.payment.ktb.adapter;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.payment.ktb.R;
import com.payment.ktb.constants.ConstantsPayType;
import com.payment.ktb.constants.ConstantsProfitType;
import com.payment.ktb.model.MessageNoticeEntity;
import com.payment.ktb.model.ProfitDetailEntity;
import com.payment.ktb.utils.StringUtils;
import com.squareup.picasso.Picasso;

import java.util.List;

/**
 * Created by admin on 2017/9/22.
 */

public class AdapterProfitDetail extends BaseAdapter {

    private Context mContext;
    private List<ProfitDetailEntity> listdatas;

    public AdapterProfitDetail(Context mContext, List<ProfitDetailEntity> listdatas) {
        this.mContext = mContext;
        this.listdatas = listdatas;
    }

    public AdapterProfitDetail() {
    }

    @Override
    public int getCount() {
        return listdatas.size();
    }

    @Override
    public Object getItem(int i) {
        return listdatas.get(i);
    }

    @Override
    public long getItemId(int i) {
        return i;
    }

    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {

        ViewHolder viewHolder = null;
        if (view == null) {
            viewHolder = new ViewHolder();
            view = View.inflate(mContext, R.layout.adapter_profitdetail_item,null);
            viewHolder.tv_profitdetail_profitPrice = (TextView) view.findViewById(R.id.tv_profitdetail_profitPrice);
            viewHolder.tv_profitdetail_amountPrice = (TextView) view.findViewById(R.id.tv_profitdetail_amountPrice);
            viewHolder.tv_profitdetail_orderTime = (TextView) view.findViewById(R.id.tv_profitdetail_orderTime);
            viewHolder.tv_profitdetail_payType = (TextView) view.findViewById(R.id.tv_profitdetail_payType);
            viewHolder.tv_profitdetail_orderNo = (TextView) view.findViewById(R.id.tv_profitdetail_orderNo);
            view.setTag(viewHolder);
        } else {
            viewHolder = (ViewHolder) view.getTag();
        }

        viewHolder.tv_profitdetail_profitPrice.setText("¥" + StringUtils.handleFen2Yuan(listdatas.get(i).getProfitPrice()));
        viewHolder.tv_profitdetail_amountPrice.setText("¥" + StringUtils.handleFen2Yuan(listdatas.get(i).getAmountPrice()));
        viewHolder.tv_profitdetail_orderTime.setText(listdatas.get(i).getOrderTime());
        viewHolder.tv_profitdetail_payType.setText(ConstantsProfitType.getType(listdatas.get(i).getProfitType()));
        viewHolder.tv_profitdetail_orderNo.setText(listdatas.get(i).getOrderNo());

        return view;
    }


    class ViewHolder {

        TextView tv_profitdetail_profitPrice;
        TextView tv_profitdetail_amountPrice;
        TextView tv_profitdetail_orderTime;
        TextView tv_profitdetail_payType;
        TextView tv_profitdetail_orderNo;

    }

}
